import pymysql

class CreateMysqlCon:
    """
    创建数据库连接对象
    """
    # 初始化数据库
    def __init__(self):
        self.con = pymysql.connect(
            host="localhost",
            port=3306,
            user="root",
            password="1234",
            database="my_blog",
            autocommit = True  # 数据库事务的开关
        )

    # 返回数据库对象
    def get_con(self):
        return self.con


